/*
 * @LastEditors: 七七
 * @Date: 2023-01-07 11:14:36
 */
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom'

class Header extends Component {

  back = () => {
    this.props.history.goBack()
  }



  render() {
    // console.log('Header收到的props：', this.props);
    return (
      <div>
        <h2>React Router Demo</h2>
        <button onClick={this.back}>回退</button>&nbsp;
        <button onClick={this.forward}>前进</button>&nbsp;
        <button onClick={this.go}>go</button>
      </div>
    );
  }
}

// !暴露withRouter加工完后的Header/withRouter调用Header后的返回值，withRouter可以接收一般组件，然后把一般组件加上路由组件所特有的api
// !withRouter的返回值是一个新组件
export default withRouter(Header);